<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="viewport" content="width=device-width,user-scalable=0"/>
    <meta charset="UTF-8">
    <title>个人信息</title>
    <script src="__api__/js/fontSize.js"></script>
    <link rel="stylesheet" href="__api__/css/bootstrap.min.css">
    <link rel="stylesheet" href="__api__/css/reset.css">
    <link rel="stylesheet" href="__api__/css/my_main.css">
    <style>
        body{
            background-color: #ebebeb;
        }
    </style>
</head>
<body>
<div class="mod_phone">
    <div class="mPhone_tit">
        <div class="container">
            <div class="tel_text">
                <p>
                    <a href="javascript:" class="active">验证原手机号</a>
                    <img src="__api__/images/right.png">
                    <a href="javascript:">更换手机号</a>
                    <img src="__api__/images/right.png">
                    <a href="javascript:">修改完成</a> </p>
            </div>
        </div>
    </div>
    <div class="phone_form">
        <div class="container">
            <form action="#" class="form-horizontal">
                <div class="form_tel">
                    <input type="tel" class="form-control" value="{$data.qi}****{$data.hou}">
                    <a  href="#" id="getcode" class="code_btn">获取验证码</a>
                </div>
                <div class="form_num">
                    <input type="text" class="form-control" placeholder="请输入验证码" name="code" id='code'>
                </div>
                <div class="form_btn">
                    <a  href="#" id="sj">验证后绑定新手机</a>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="__assets__/layui.js"></script>
<script src="__assets__/js/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
	var layer;
	layui.use('layer', function(){
		   layer = layui.layer;
		  
		  //layer.msg('hello');
		});     
	$('#getcode').click(function(){
		var url="{:url('api/user/getTextValidateCode')}";
		var telphone="{$data.tel}";
		//console.log(telphone);
		var data={telphone:telphone};
		$.get(url,data,function(res){
			var obj=eval('(' + res +')');
			var status=obj.status;
			var info=obj.info;
			if(status==200){
				layer.msg(info,{icon:6});
			}else if(status==-1){
				layer.msg(info,{icon:5});
			}else if(status==414){
				layer.msg(info,{icon:5});
			}else{
				layer.msg(info,{icon:5});
			}
		})
	});
	$('#sj').click(function(){
		var url="{:url('api/user/checkTextValidateCodes')}";
		var sucess_url="{:url('api/Userinfo/modphone2')}";
		var telphone="{$data.tel}";
		var code=$('#code').val();
		var data={telphone:telphone,code:code};
		$.post(url,data,function(res){
			var obj=eval('(' + res +')');
			var status=obj.status;
			var info=obj.info;
			if(status==-1){
				layer.msg(info,{icon:5});
			}else if(status==200){
				layer.msg(info,{icon:6},function(){
					window.location.href=sucess_url;
				});
			}else{
				layer.msg(info,{icon:5});
			}
		})
	})
})

</script>
</body>
</html>